 
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <signal.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
using namespace std;
time_t clocktime() {
  /*
  time_t t= time(NULL);
  std::cout<<" s秒级 ----:";
  std::cout<<t<<endl;
  */
  struct timeval tv;
  gettimeofday(&tv, NULL);
  std::cout << "10e6 微秒级s ----:";
  std::cout << tv.tv_sec << "s," << tv.tv_usec << "微秒" << endl;
}
 
 
 
static int count = 0;
static struct itimerval oldtv;
 
void set_timer()
{
    struct itimerval itv;
    itv.it_interval.tv_sec = 0;
    itv.it_interval.tv_usec = 200000;
    itv.it_value.tv_sec = 0;
    itv.it_value.tv_usec = 100000;
    setitimer(ITIMER_REAL, &itv, &oldtv);
}
 
void signal_handler(int m)
{
    count ++;
    printf("%d\n", count);
clocktime();
usleep(20000);
}
 
int main()
{
    signal(SIGALRM, signal_handler);
    set_timer();
    while(count < 10000);
    exit(0);
    return 1;
}
 